﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace ApiScanner
{
    public static class EnumerableExtension
    {
        public static IEnumerable<T> ComEnumerate<T>(this IEnumerable items)
        {
            if (items == null) throw new ArgumentNullException("items");
            foreach (var item in items)
            {
                yield return (T) item;
                Marshal.ReleaseComObject(item);
            }
        }
    }
}
